#1. 确定CMake的最低版本需求
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)

#2. 确定工程名
PROJECT(QuoteFactory LANGUAGES CXX)
SET(CMAKE_CXX_STANDARD 11)

SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build_${PLATFORM}/${CMAKE_BUILD_TYPE}/bin/QuoteFactory)

#7. 添加源码
FILE( GLOB SRCS *.cpp)

IF(MSVC)
	list (APPEND SRCS ../Common/mdump.cpp)
ENDIF()

INCLUDE_DIRECTORIES(${INCS})
LINK_DIRECTORIES(${LNKS})

SET(LIBS
	WTSTools
	WTSUtils
	WtDtCore)

IF(MSVC)
	LIST(APPEND LIBS ws2_32)
ELSE(GNUCC)
	LIST(APPEND LIBS
		dl
		boost_filesystem
        	pthread
		)
	if(WIN32)
		LIST(APPEND LIBS
			ws2_32 iconv)
	ENDIF()
ENDIF()

#9. 生成可执行文件
ADD_EXECUTABLE(QuoteFactory ${SRCS})
TARGET_LINK_LIBRARIES(QuoteFactory ${LIBS})

IF (MSVC)
ELSE (GNUCC)
	SET_TARGET_PROPERTIES(QuoteFactory PROPERTIES
        LINK_FLAGS_RELEASE -s)
ENDIF ()

file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/parsers/)
add_custom_command(TARGET QuoteFactory POST_BUILD
	COMMAND ${CMAKE_COMMAND} -E
	copy ${CMAKE_BINARY_DIR}/build_${PLATFORM}/${CMAKE_BUILD_TYPE}/bin/${PREFIX}ParserCTP${SUFFIX} ${EXECUTABLE_OUTPUT_PATH}/parsers/

	COMMAND ${CMAKE_COMMAND} -E
	copy ${CMAKE_BINARY_DIR}/build_${PLATFORM}/${CMAKE_BUILD_TYPE}/bin/${PREFIX}ParserXTP${SUFFIX} ${EXECUTABLE_OUTPUT_PATH}/parsers/

	COMMAND ${CMAKE_COMMAND} -E
	copy ${CMAKE_BINARY_DIR}/build_${PLATFORM}/${CMAKE_BUILD_TYPE}/bin/${PREFIX}ParserFemas${SUFFIX} ${EXECUTABLE_OUTPUT_PATH}/parsers/

	COMMAND ${CMAKE_COMMAND} -E
	copy ${CMAKE_BINARY_DIR}/build_${PLATFORM}/${CMAKE_BUILD_TYPE}/bin/${PREFIX}ParserCTPMini${SUFFIX} ${EXECUTABLE_OUTPUT_PATH}/parsers/

	COMMAND ${CMAKE_COMMAND} -E
	copy ${CMAKE_BINARY_DIR}/build_${PLATFORM}/${CMAKE_BUILD_TYPE}/bin/${PREFIX}WtDataStorage${SUFFIX} ${EXECUTABLE_OUTPUT_PATH}/

	COMMENT "depends modules copied")


